ALMaSS  1.0
The Animal, Landscape and Man Simulation System
RoeDeer_Population_Manager Class Reference

#include <Roe_all.h>

Inheritance diagram for RoeDeer_Population_Manager:
Population_Manager

Public Member Functions

int CreateNewGroup (Roe_Base *p_deer)
 
size_t Supply_GroupSize (int Group)
 
double Supply_AverageRangeQuality ()
 
double RangeQuality (int p_x, int p_y, int p_range)
 
double PercentForest (int p_x, int p_y, int p_range)
 
bool AddToGroup (Roe_Base *p_deer, int TheGroup)
 
bool RemoveFromGroup (Roe_Base *p_deer, int TheGroup)
 
void RemoveFromFightlist (Roe_Base *deer)
 
ListOfDeerSupply_RoeGroup (int Group)
 
bool InSquare (int p_x, int p_y, int p_sqx, int p_sqy, int p_range)
 
void CalculateArea (int p_a, int p_b, int ID)
 
int ScanGrid (int p_x, int p_y, bool avq)
 
int AddToArea (int g_x, int g_y, int p_range)
 
int AddToAreaCC (int g_x, int g_y, int p_range)
 
void Sort (int ID, int p_a, int p_b)
 
void Divide1 (int ID, int p_a, int p_b)
 
void Divide2 (int p_a, int p_b, int p_c, bool p_upper)
 
ListOfMalesSupplyFightlist (int ListNo)
 
void DeleteFightlist (int TheList)
 
int AddToFightlist (Roe_Male *rival, int ListNo)
 
int GetFixList ()
 
void RemoveFixList (int listno)
 
void PreProcessLandscape ()
 
void UpdateRanges ()
 
virtual void TheAOROutputProbe ()
 
virtual void TheRipleysOutputProbe (FILE *a_prb)
 
 RoeDeer_Population_Manager (Landscape *L)
 
 ~RoeDeer_Population_Manager ()
 
virtual void Init (void)
 
void CreateObjects (int, TAnimal *pvo, void *null, Deer_struct *data, int number)
 
ListOfMalesSupplyMales (int p_x, int p_y, int SearchRange)
 
ListOfMalesSupplyTMales (int p_x, int p_y, int SearchRange)
 
ListOfMalesSupplyMaleRC (int p_x, int p_y, int SearchRange)
 
ListOfFemalesSupplyFemales (int p_x, int p_y, int SearchRange)
 
ListOfFemalesSupplyFemaleRC (int p_x, int p_y, int SearchRange)
 
void LOG (int day, int year)
 
- Public Member Functions inherited from Population_Manager
 Population_Manager (Landscape *L)
 
virtual ~Population_Manager (void)
 
void SetNoProbes (int a_pn)
 
unsigned GetLiveArraySize (int a_listindex)
 Gets the number of 'live' objects for a list index in the TheArray. More...
 
void IncLiveArraySize (int a_listindex)
 Increments the number of 'live' objects for a list index in the TheArray. More...
 
virtual void Catastrophe (int)
 
unsigned int FarmAnimalCensus (unsigned int a_farm, unsigned int a_typeofanimal)
 
char * SpeciesSpecificReporting (int a_species, int a_time)
 
char * ProbeReport (int a_time)
 
char * ProbeReportTimed (int a_time)
 
void ImpactProbeReport (int a_Time)
 
bool BeginningOfMonth ()
 
void LOG (const char *fname)
 
int SupplyStepSize ()
 
int SupplySimW ()
 
int SupplySimH ()
 
virtual void Run (int NoTSteps)
 
virtual float Probe (int ListIndex, probe_data *p_TheProbe)
 
virtual void ImpactedProbe ()
 
int SupplyListNameLength ()
 
TAnimalSupplyAnimalPtr (int a_index, int a_animal)
 Returns the pointer indexed by a_index and a_animal. Note NO RANGE CHECK. More...
 
unsigned SupplyListIndexSize ()
 
unsigned SupplyListSize (unsigned listindex)
 
bool CheckXY (int l, int i)
 Debug method to test for out of bounds coordinates. More...
 
const char * SupplyListName (int i)
 
bool IsLast (unsigned listindex)
 
int SupplyState (unsigned listindex, unsigned j)
 
virtual void SupplyLocXY (unsigned listindex, unsigned j, int &x, int &y)
 
const char * SupplyStateNames (int i)
 
unsigned SupplyStateNamesLength ()
 
virtual void DisplayLocations ()
 
int ProbeFileInput (char *p_Filename, int p_ProbeNo)
 
TAnimalFindClosest (int x, int y, unsigned Type)
 
bool OpenTheRipleysOutputProbe (string a_NWordFilename)
 
void OpenTheAOROutputProbe (string a_AORFilename)
 
bool OpenTheMonthlyRipleysOutputProbe ()
 
bool OpenTheReallyBigProbe ()
 
virtual void TheReallyBigOutputProbe ()
 
void CloseTheMonthlyRipleysOutputProbe ()
 
virtual void CloseTheRipleysOutputProbe ()
 
virtual void CloseTheReallyBigOutputProbe ()
 
TTypesOfPopulation GetPopulationType ()
 
int GetSeasonNumber ()
 Get the season number. More...
 
void LamdaDeath (int x, int y)
 
void LamdaBirth (int x, int y)
 
void LamdaBirth (int x, int y, int z)
 
void LamdaClear ()
 
void LamdaDumpOutput ()
 
virtual int SupplyPegPosx (int)
 
virtual int SupplyPegPosy (int)
 
virtual int SupplyCovPosx (int)
 
virtual int SupplyCovPosy (int)
 
virtual bool OpenTheFledgelingProbe ()
 
virtual bool OpenTheBreedingPairsProbe ()
 
virtual bool OpenTheBreedingSuccessProbe ()
 
virtual void BreedingPairsOutput (int)
 
virtual int TheBreedingFemalesProbe (int)
 
virtual int TheFledgelingProbe ()
 
virtual void BreedingSuccessProbeOutput (double, int, int, int, int, int, int, int)
 
virtual int TheBreedingSuccessProbe (int &, int &, int &, int &, int &, int &)
 
virtual void FledgelingProbeOutput (int, int)
 
virtual void TheGeneticProbe (unsigned, int, unsigned &)
 
virtual void GeneticsResultsOutput (FILE *, unsigned)
 

Public Attributes

MovementMapm_MoveMap
 Map of suitability for movement. More...
 
int DeadList [2000][2]
 
long StepCounter
 
int m_MaleDispThreshold
 
int m_FemaleDispThreshold
 
int m_MinWeight_Males
 
int m_MinWeight_Females
 
int m_CriticalWeight_Males
 
int m_CriticalWeight_Females
 
int SimW
 
int SimH
 
- Public Attributes inherited from Population_Manager
int IndexArrayX [5][10000]
 
probe_dataTheProbe [100]
 
int SimH
 
int SimW
 
unsigned SimHH
 
unsigned SimWH
 
char m_SimulationName [255]
 
bool ProbesSet
 
Landscapem_TheLandscape
 

Protected Member Functions

void DoFirst ()
 
void RunFirst ()
 
void RunBefore ()
 
void RunAfter ()
 
void RunLast ()
 
- Protected Member Functions inherited from Population_Manager
virtual bool StepFinished ()
 Overrides the population manager StepFinished - there is no chance that hunters do not finish a step behaviour. More...
 
virtual void DoBefore ()
 
virtual void DoAfter ()
 
virtual void DoAlmostLast ()
 
virtual void DoLast ()
 
void EmptyTheArray ()
 Removes all objects from the TheArray by deleting them and clearing TheArray. More...
 
void SortX (unsigned Type)
 
void SortXIndex (unsigned Type)
 
void SortY (unsigned Type)
 
void SortState (unsigned Type)
 
void SortStateR (unsigned Type)
 
unsigned PartitionLiveDead (unsigned Type)
 
void Shuffle_or_Sort (unsigned Type)
 
void Shuffle (unsigned Type)
 
virtual void Catastrophe ()
 

Protected Attributes

Roe_Gridm_TheGrid
 
ListOfDeerm_GroupList [5000]
 
int m_NoGroups
 
double m_AverageRangeQuality
 
int m_FixCounter [5000]
 
ListOfMalesm_Fightlist [5000]
 
long m_totalarea
 
int Turnover
 
int m_FixList [5000][20][2]
 
unsigned m_UpperList [100][2]
 
unsigned m_LowerList [100][2]
 
int m_gridextentx
 The number of cells wide in the qual grid. More...
 
int m_gridextenty
 The number of cells tall in the qual grid. More...
 
- Protected Attributes inherited from Population_Manager
vector< unsigned > m_LiveArraySize
 
int m_NoProbes
 
AOR_Probem_AOR_Probe
 
FILE * m_GeneticsFile
 
FILE * m_AlleleFreqsFile
 
FILE * m_EasyPopRes
 
const char * StateNames [100]
 
int m_catastrophestartyear
 
int m_StepSize
 
vector< TListOfAnimalsTheArray
 
unsigned StateNamesLength
 
const char * m_ListNames [32]
 
unsigned m_ListNameLength
 
FILE * TestFile
 
FILE * TestFile2
 
unsigned BeforeStepActions [12]
 
int m_SeasonNumber
 Holds the season number. Used when running goose and hunter sims. More...
 
TTypesOfPopulation m_population_type
 
ofstream * AOROutputPrb
 
FILE * RipleysOutputPrb
 
FILE * RipleysOutputPrb1
 
FILE * RipleysOutputPrb2
 
FILE * RipleysOutputPrb3
 
FILE * RipleysOutputPrb4
 
FILE * RipleysOutputPrb5
 
FILE * RipleysOutputPrb6
 
FILE * RipleysOutputPrb7
 
FILE * RipleysOutputPrb8
 
FILE * RipleysOutputPrb9
 
FILE * RipleysOutputPrb10
 
FILE * RipleysOutputPrb11
 
FILE * RipleysOutputPrb12
 
FILE * ReallyBigOutputPrb
 
long int lamdagrid [2][257][257]
 

Constructor & Destructor Documentation

◆ RoeDeer_Population_Manager()

RoeDeer_Population_Manager::RoeDeer_Population_Manager ( Landscape L)
28 {
29  m_TheGrid = new Roe_Grid(L);
30  Turnover=0; //total number of individuals created during a simulation
31  StepCounter=0;
38  m_totalarea = 0;
39 
40  // empty all the group pointers
41  for (int i=0; i<MaxNoDeer; i++)
42  {
43  m_GroupList[i]=NULL;
44  m_FixCounter[i] = -1;
45  m_Fightlist[i] =NULL; // ljk 2/7 2012
46  }
47 
48 
49  m_NoGroups=0;
50 
51  // Get SimW & SimH (landscape size)
54  // Three lists are needed so need to remove 7 of the ten default arrays
55  // Fawn, male, Female
56  for (int i=0; i<7; i++)
57  {
58  TheArray.pop_back();
59  }
60  m_MoveMap=new MovementMap(L, 8); // 8 for roe deer //**ljk inserted on 25/7-2012
61  Init();
62 }
const int MaxNoDeer
Definition: Roe_constants.cpp:26
int SupplySimAreaHeight(void)
Definition: landscape.h:1637
int SupplySimAreaWidth(void)
Definition: landscape.h:1632
Movement maps are used for rapid computing of animal movement.
Definition: MovementMap.h:51
Population_Manager(Landscape *L)
Definition: PopulationManager.cpp:221
vector< TListOfAnimals > TheArray
Definition: PopulationManager.h:534
Definition: Roe_all.h:465
int SimH
Definition: Roe_all.h:530
int m_CriticalWeight_Males
Definition: Roe_all.h:510
int m_NoGroups
Definition: Roe_all.h:488
int m_MinWeight_Females
Definition: Roe_all.h:509
int m_FixCounter[5000]
Definition: Roe_all.h:490
long StepCounter
Definition: Roe_all.h:505
Roe_Grid * m_TheGrid
Definition: Roe_all.h:486
int m_CriticalWeight_Females
Definition: Roe_all.h:511
int Turnover
Definition: Roe_all.h:493
virtual void Init(void)
Definition: Roe_Population_Manager.cpp:75
int SimW
Definition: Roe_all.h:529
ListOfMales * m_Fightlist[5000]
Definition: Roe_all.h:491
int m_FemaleDispThreshold
Definition: Roe_all.h:507
MovementMap * m_MoveMap
Map of suitability for movement.
Definition: Roe_all.h:503
long m_totalarea
Definition: Roe_all.h:492
int m_MaleDispThreshold
Definition: Roe_all.h:506
int m_MinWeight_Males
Definition: Roe_all.h:508
ListOfDeer * m_GroupList[5000]
Definition: Roe_all.h:487

References Init(), m_CriticalWeight_Females, m_CriticalWeight_Males, m_FemaleDispThreshold, m_Fightlist, m_FixCounter, m_GroupList, m_MaleDispThreshold, m_MinWeight_Females, m_MinWeight_Males, m_MoveMap, m_NoGroups, m_TheGrid, m_totalarea, MaxNoDeer, SimH, SimW, StepCounter, Landscape::SupplySimAreaHeight(), Landscape::SupplySimAreaWidth(), Population_Manager::TheArray, and Turnover.

◆ ~RoeDeer_Population_Manager()

RoeDeer_Population_Manager::~RoeDeer_Population_Manager ( )
65 {
66  delete m_TheGrid;
67 }

References m_TheGrid.

Member Function Documentation

◆ AddToArea()

int RoeDeer_Population_Manager::AddToArea ( int  g_x,
int  g_y,
int  p_range 
)

RoeDeer_Population_Manager::AddToArea - Coordinates not corrected for wrap-around. Function sums up the quality in a layer of grid cells of size p_range x p_range Calls function Supply_GridValue().

374 {
375  /*Coordinates not corrected . Starting in grid coordinates g_x,g_y this
376  function summs up the quality in a layer of grid cells of size p_range x p_range*/
377 
378  int quali = 0;
379  int length = 2*p_range; //size of the square
380 
381  for (int i=0; i< length;i++) //top and bottom row
382  {
383  quali += m_TheGrid->Supply_GridValue(g_x,g_y);
384  quali += m_TheGrid->Supply_GridValue (g_x,g_y+length);
385  g_x ++; //move right to next cell
386  }
387  //Don't want to count corner cells twice so increment g_y before function call
388  //and subtract 2 from length
389  for (int i=0; i< length-2;i++) //left and right column
390  {
391  g_y ++; //move down to next cell
392  quali += m_TheGrid->Supply_GridValue(g_x-length,g_y);
393  quali += m_TheGrid->Supply_GridValue (g_x,g_y);
394  }
395  return quali;
396 }
int Supply_GridValue(int g_x, int g_y)
Definition: Roe_grid.cpp:69

References m_TheGrid, and Roe_Grid::Supply_GridValue().

Referenced by ScanGrid().

◆ AddToAreaCC()

int RoeDeer_Population_Manager::AddToAreaCC ( int  g_x,
int  g_y,
int  p_range 
)

RoeDeer_Population_Manager::AddToAreaCC - Coordinates corrected for wrap-around landscape. Function sums up the quality in a layer of grid cells of size p_range x p_range. Calls function Supply_GridValue().

405 {
406  /* Coordinates corrected. Starting in grid coordinates g_x,g_y this function
407  summs up the quality in a layer of grid cells of size p_range x p_range*/
408 
409  int quali = 0;
410  int length = 2 * p_range; //size of the square
411 
412  g_x += m_gridextentx;
413  g_y += m_gridextenty;
414  for (int i=0; i< length;i++) //top and bottom row
415  {
417  quali += m_TheGrid->Supply_GridValue(g_x%m_gridextentx, (g_y + length) % m_gridextenty);
418  g_x ++; //move right to next cell
419  }
420  //Don't want to count corner cells twice so increment g_y before function call
421  //and subtract 2 from length
422  for (int i=0; i< length-2;i++) //left and right column
423  {
424  g_y ++; //move down to next cell
425  quali += m_TheGrid->Supply_GridValue((g_x - length) % m_gridextentx, g_y%m_gridextenty);
427  }
428  return quali;
429 }
int m_gridextenty
The number of cells tall in the qual grid.
Definition: Roe_all.h:500
int m_gridextentx
The number of cells wide in the qual grid.
Definition: Roe_all.h:498

References m_gridextentx, m_gridextenty, m_TheGrid, and Roe_Grid::Supply_GridValue().

Referenced by ScanGrid().

◆ AddToFightlist()

int RoeDeer_Population_Manager::AddToFightlist ( Roe_Male rival,
int  ListNo 
)

RoeDeer_Population_Manager::AddToFightlist - adds rival males to fightlist or creates a fightlist if a male object does not have one. Also checks if rival is on list already.

1528 {
1529  #ifdef JUJ__Debug3
1530  if(rival->IsAlive()!=0x0DEADC0DE)
1531  {
1532  m_TheLandscape ->Warn("Roe_Population_Manager:AddToFightList():Deadcode warning,rival!","");
1533  exit( 1 );
1534  }
1535  #endif
1536  bool found=false;
1537  ListOfMales* fightlist = m_Fightlist[ListNo];
1538 
1539  if (ListNo==-1) //need to create new list
1540  {
1541  for(int i=0;i<5000;i++)
1542  {
1543  if (m_Fightlist[i]==NULL)
1544  {
1545  // Creates a new list
1546  m_Fightlist[i]=new ListOfMales;
1547  // add the rival to the list
1548  m_Fightlist[i]->push_back(rival);
1549  ListNo=i; //the number of this list
1550  found=true;
1551  break;
1552  }
1553  }
1554  if(found==false)
1555  {
1556  m_TheLandscape ->Warn("Roe_Population_Manager:RemoveFromFightList():List not found!","");
1557  exit( 1 );
1558  }
1559  }
1560  else //a list exists already
1561  {
1562 
1563  //check if rival is on fightlist already
1564  for(unsigned i=0;i<fightlist->size();i++)
1565  {
1566  if((*fightlist)[i]==rival)
1567  {
1568  found=true;
1569  break;
1570  }
1571  }
1572  if(!found)
1573  {
1574  // record the new member
1575  m_Fightlist[ListNo]->push_back(rival);
1576  }
1577  }
1578  return ListNo;
1579 }
vector< Roe_Male * > ListOfMales
Definition: Roe_all.h:39
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1579
Landscape * m_TheLandscape
Definition: PopulationManager.h:515
unsigned IsAlive()
Definition: Roe_all.h:123

References Roe_Base::IsAlive(), m_Fightlist, Population_Manager::m_TheLandscape, and Landscape::Warn().

Referenced by Roe_Male::BeginStep(), Roe_Male::MEstablishTerritory(), Roe_Male::On_InHeat(), and Roe_Male::On_Rank().

◆ AddToGroup()

bool RoeDeer_Population_Manager::AddToGroup ( Roe_Base p_deer,
int  TheGroup 
)
1398 {
1399  // CJT Added
1400  if (TheGroup==-1) return false; // CJT return value is not used
1401  #ifdef JUJ__Debug1
1402  if(p_deer==NULL)
1403  {
1404  m_TheLandscape ->Warn("Roe_Population_Manager:AddToGroup(): NULL pointer,p_deer!","");
1405  exit( 1 );
1406  }
1407  #endif
1408  #ifdef JUJ__Debug3
1409  if(p_deer->IsAlive()!=0x0DEADC0DE)
1410  {
1411  m_TheLandscape ->Warn("Roe_Population_Manager:AddToGroup():Deadcode warning,p_deer!","");
1412  exit( 1 );
1413  }
1414  #endif
1415 
1416  if(m_GroupList[TheGroup]==NULL)
1417  {
1418  m_TheLandscape ->Warn("Roe_Population_Manager:AddToGroup(): NULL pointer,m_GroupList[TheGroup]!","");
1419  exit( 1 );
1420  }
1421  // record the new member
1422  m_GroupList[TheGroup]->push_back(p_deer);
1423  return true;
1424 }

References Roe_Base::IsAlive(), m_GroupList, Population_Manager::m_TheLandscape, and Landscape::Warn().

Referenced by Roe_Female::AddFawnToList(), Roe_Female::FFormGroup(), Roe_Fawn::On_ChangeGroup(), and Roe_Female::Roe_Female().

◆ CalculateArea()

void RoeDeer_Population_Manager::CalculateArea ( int  p_a,
int  p_b,
int  ID 
)
902 {
903 /* Calculate the area of the convex hull containing all the locations
904  in m_FixList and write the result to file
905  1: sort according to increasing x and yvalues
906  2: find Left, Right
907  3: for each point decide which are above and below the lr-line
908  4: find h that gives the triangle with max area
909  5: eliminate all points within the triangle
910  6: calculate area of lrh and add to total area
911  7: repeat for lower hull
912  8: repeat recursively for the 4 (max) new subsets adding the area of
913  each triangle to total
914  9: write total area to file with a reference to deer
915  Makes use of 3 methods; Sort(),Divide1(), Divide2() */
916  //first sort the array
917  Sort (ID,p_a,p_b); //recursive
918  //now divide the points above and below the line, m_UpperList and m_LowerList
919  Divide1(ID,p_a,p_b); //initial division of m_FixList, Divide1 calls Divide2
920 }
void Sort(int ID, int p_a, int p_b)
Definition: Roe_Population_Manager.cpp:1083
void Divide1(int ID, int p_a, int p_b)
Definition: Roe_Population_Manager.cpp:922

References Divide1(), and Sort().

◆ CreateNewGroup()

int RoeDeer_Population_Manager::CreateNewGroup ( Roe_Base p_deer)

RoeDeer_Population_Manager::CreateNewGroup - creates a new group and adds the calling deer to that group.

1369 {
1370  #ifdef JUJ__Debug3
1371  if(p_deer->IsAlive()!=0x0DEADC0DE)
1372  {
1373  m_TheLandscape ->Warn("Roe_Population_Manager:CreateNewGroup():Deadcode warning,p_deer!","");
1374  exit( 1 );
1375  }
1376  #endif
1377  // Creates a new group and adds the calling deer to that group
1378  //find a vacant group number
1379  int number=-1;
1380  for(int i=0;i<MaxNoGroups;i++)
1381  {
1382  if(m_GroupList[i]==NULL)
1383  {
1384  number=i;
1385  break;
1386  }
1387  }
1388  m_GroupList[number]=new ListOfDeer;
1389  // add the first group member
1390  m_GroupList[number]->push_back(p_deer);
1391  // Record the number of groups now
1392  m_NoGroups++;
1393  return number;
1394 
1395 }
vector< Roe_Base * > ListOfDeer
Definition: Roe_all.h:41
const int MaxNoGroups
Definition: Roe_constants.cpp:25

References Roe_Base::IsAlive(), m_GroupList, m_NoGroups, Population_Manager::m_TheLandscape, MaxNoGroups, and Landscape::Warn().

Referenced by Roe_Female::FEstablishRange(), and Roe_Female::Roe_Female().

◆ CreateObjects()

void RoeDeer_Population_Manager::CreateObjects ( int  ob_type,
TAnimal pvo,
void *  null,
Deer_struct data,
int  number 
)
1269 {
1270  Roe_Fawn *New_Fawn;
1271  Roe_Male *New_Male;
1272  Roe_Female *New_Female;
1273  Roe_Female* mum;
1274  for (int i=0; i<number; i++)
1275  {
1276  Turnover++;
1277 
1278  if (ob_type == 0)
1279  {
1280  New_Fawn = new Roe_Fawn(data->x, data->y,data->size,data->group,data->sex,data-> L,this);
1281  TheArray[ob_type].push_back(New_Fawn);
1282  mum=dynamic_cast <Roe_Female*> (pvo);
1283  //Mum handles the adding to lists
1284  New_Fawn->Mum = mum;
1285  New_Fawn->m_ID=Turnover; //fawns always need a new ID
1286  New_Fawn->Mum->AddFawnToList(New_Fawn);
1287  //WriteIDFile("Sex.txt", New_Fawn->m_ID, New_Fawn->m_Sex);
1288  }
1289  if (ob_type == 1)
1290  {
1291  // Male
1292  New_Male = new Roe_Male(data->x, data->y,data->size,data->age,data->mum,data-> L,this);
1293  TheArray[ob_type].push_back(New_Male);
1294  if (data->ID!=-1) //maturing fawn
1295  {
1296  Turnover--;
1297  New_Male->m_ID=data->ID;
1298  }
1299  else New_Male->m_ID = Turnover; //new individual
1300  New_Male->m_FixlistNumber = GetFixList(); //all adults need a place to store their fixes
1301  }
1302  if (ob_type == 2)
1303  {
1304 // for posterity data=dynamic_cast<AdultDeer_struct *>(data);
1305  // Female
1306  New_Female = new Roe_Female(data->x, data->y,data->size,data->age,data->group,data->mum,data-> L,this);
1307  TheArray[ob_type].push_back(New_Female);
1308  if (data->ID!=-1) //maturing fawn
1309  {
1310  Turnover--;
1311  New_Female->m_ID=data->ID;
1312  //debug
1313  }
1314  else New_Female->m_ID = Turnover;
1315  New_Female->m_FixlistNumber = GetFixList(); //all adults need a place to store their fixes
1316  }
1317  }
1318 }
int x
Definition: Roe_all.h:439
int age
Definition: Roe_all.h:447
int size
Definition: Roe_all.h:446
int ID
Definition: Roe_all.h:448
bool sex
Definition: Roe_all.h:441
int y
Definition: Roe_all.h:440
int group
Definition: Roe_all.h:445
Roe_Female * mum
Definition: Roe_all.h:444
int m_FixlistNumber
Definition: Roe_all.h:119
Roe_Female * Mum
Definition: Roe_all.h:117
int m_ID
Definition: Roe_all.h:118
Definition: Roe_all.h:254
Definition: Roe_all.h:309
void AddFawnToList(Roe_Fawn *fawn)
Definition: Roe_female.cpp:1368
Definition: Roe_all.h:380
int GetFixList()
Definition: Roe_Population_Manager.cpp:1320

References Roe_Female::AddFawnToList(), Deer_struct::age, GetFixList(), Deer_struct::group, Deer_struct::ID, Roe_Base::m_FixlistNumber, Roe_Base::m_ID, Roe_Base::Mum, Deer_struct::mum, Deer_struct::sex, Deer_struct::size, Population_Manager::TheArray, Turnover, Deer_struct::x, and Deer_struct::y.

Referenced by Roe_Female::FGiveBirth(), Init(), and Roe_Fawn::Mature().

◆ DeleteFightlist()

void RoeDeer_Population_Manager::DeleteFightlist ( int  TheList)
1628 {
1629  if(m_Fightlist[TheList] !=NULL)
1630  {
1631  delete m_Fightlist[TheList]; //delete the list
1632  m_Fightlist[TheList]=NULL;
1633  }
1634 }

References m_Fightlist.

Referenced by Roe_Male::MDie().

◆ Divide1()

void RoeDeer_Population_Manager::Divide1 ( int  ID,
int  p_a,
int  p_b 
)
923 { //TODO need to check home range results with fixfile!!
924 
925  //create 2 new subarrays, upper starts with min and ends with max
926  long u_area=0;
927  long l_area=0;
928  int u_c=0;
929  int l_c=0;
930  int u_N=0;
931  int l_N=0;
932  for (int i=0; i< p_b;i++) //for all points on list
933  { //Calculates twice the area, if area >= 0 then a point belongs to upper,
934  //else to lower
935  long area = m_FixList[ID][i][0]*(m_FixList[ID][p_a][1]-m_FixList[ID][p_b][1]) +
936  m_FixList[ID][p_a][0]*(m_FixList[ID][p_b][1]-m_FixList[ID][i][1]) +
937  m_FixList[ID][p_b][0]*(m_FixList[ID][i][1]- m_FixList[ID][p_a][1]);
938 
939  if (area > 0) //belongs to upper
940  {
941  //add to upper
942  m_UpperList[i][0]=m_FixList[ID][i][0];
943  m_UpperList[i][1]=m_FixList[ID][i][1];
944  u_N++;
945  if (area > u_area) //so far this is the largest triangle
946  {
947  u_area = area;
948  u_c=i; //the 3rd corner in largest triangle
949  }
950  }
951  else if(area < 0)
952  {
953  //add to lower
954  m_LowerList[i][0]=m_FixList[ID][i][0];
955  m_LowerList[i][1]=m_FixList[ID][i][1];
956  l_N++;
957  if (area*-1 > l_area)
958  {
959  l_area = area*-1; //positive area
960  l_c = i;
961  }
962  }
963  }
964  //add areas to total
965  m_totalarea += (u_area+l_area)/2;
966  //now call Divide2 to do the calculations on the subarrays
967  Divide2(0,u_N,u_c,true); //upper list
968  Divide2(0,l_N,l_c,false); //lower list
969 }
unsigned m_UpperList[100][2]
Definition: Roe_all.h:495
unsigned m_LowerList[100][2]
Definition: Roe_all.h:496
int m_FixList[5000][20][2]
Definition: Roe_all.h:494
void Divide2(int p_a, int p_b, int p_c, bool p_upper)
Definition: Roe_Population_Manager.cpp:971

References Divide2(), m_FixList, m_LowerList, m_totalarea, and m_UpperList.

Referenced by CalculateArea().

◆ Divide2()

void RoeDeer_Population_Manager::Divide2 ( int  p_a,
int  p_b,
int  p_c,
bool  p_upper 
)
972 { //divide the 2 subarrays further, recursive function
973  int u_N=-1;
974  int l_N=-1;
975  long l_area=0;
976  long r_area=0;
977  int l_c=0;
978  int r_c=0;
979  int l_index=-1;
980  int r_index=-1;
981  int l_list[72],r_list[72];
982  if (p_upper==true) //do upper array
983  {
984  for (int i=p_a; i< p_b;i++) //for all points on list
985  {
986  //Calculates twice the area with respect to aci and cbi, if area >= 0
987  //then a point belongs to upper, else to lower
988  long area1 = m_UpperList[i][0]*(m_UpperList[p_a][1]-m_UpperList[p_c][1]) +
989  m_UpperList[p_a][0]*(m_UpperList[p_c][1]-m_UpperList[i][1]) +
990  m_UpperList[p_c][0]*(m_UpperList[i][1]- m_UpperList[p_a][1]);
991  if (area1 > 0)
992  {
993  l_index++;
994  l_list[l_index]=i;
995  u_N++;
996  if (area1 > l_area)
997  {
998  l_area = area1;
999  l_c = i;
1000  }
1001  }
1002  else if (area1 < 0)
1003  {
1004  long area2 = m_UpperList[i][0]*(m_UpperList[p_c][1]-m_UpperList[p_b][1]) +
1005  m_UpperList[p_c][0]*(m_UpperList[p_b][1]-m_UpperList[i][1]) +
1006  m_UpperList[p_b][0]*(m_UpperList[i][1]- m_UpperList[p_c][1]);
1007 
1008  if (area2 > 0)
1009  {
1010  r_index++;
1011  r_list[r_index]=i;
1012  u_N++;
1013  if (area2 > r_area) //so far this is the largest triangle
1014  {
1015  r_area = area2;
1016  r_c=i; //the 3rd corner in largest triangle
1017  }
1018  } //ignore lower part of the set
1019  }
1020  }
1021  }
1022 
1023  else //do lower subarray
1024  {
1025  for (int i=p_a; i< p_b;i++) //for all points on list
1026  {
1027  //Calculates twice the area with respect to aci and cbi, if area >= 0
1028  //then a point belongs to upper, else to lower
1029  long area1 = m_LowerList[i][0]*(m_LowerList[p_a][1]-m_LowerList[p_c][1]) +
1030  m_LowerList[p_a][0]*(m_LowerList[p_c][1]-m_LowerList[i][1]) +
1031  m_LowerList[p_c][0]*(m_LowerList[i][1]- m_LowerList[p_a][1]);
1032  if (area1>0)
1033  {
1034  l_index++;
1035  l_list[l_index]=i;
1036  l_N++;
1037  if (area1 > l_area)
1038  {
1039  l_area = area1;
1040  l_c = i;
1041  }
1042  }
1043  else
1044  {
1045  long area2 = m_LowerList[i][0]*(m_LowerList[p_c][1]-m_LowerList[p_b][1]) +
1046  m_LowerList[p_c][0]*(m_LowerList[p_b][1]-m_LowerList[i][1]) +
1047  m_LowerList[p_b][0]*(m_LowerList[i][1]- m_LowerList[p_c][1]);
1048 
1049  if (area2 > 0)
1050  {
1051  r_index++;
1052  r_list[r_index]=i;
1053  if (area2 > r_area) //so far this is the largest triangle
1054  {
1055  r_area = area2;
1056  r_c=i; //the 3rd corner in largest triangle
1057  }
1058  }
1059  }
1060  }
1061  }
1062  //add area to total
1063  m_totalarea += (l_area+r_area)/2;
1064  //r_index and l_index now indicates whether there are any locations left
1065  if(l_index>0)
1066  {
1067  if (r_index>0) //call for both left and right
1068  {
1069  //points left on both sides, make a local store of a, b and c
1070  int a = l_list[0];
1071  int b = l_list[l_index];
1072  int c = l_c;
1073  Divide2(r_list[0],r_list[r_index],r_c,p_upper);
1074  Divide2(a,b,c,p_upper);
1075  }
1076  else //only call for left
1077  {
1078  Divide2(l_list[0],l_list[l_index],l_c,p_upper);
1079  }
1080  }
1081 }

References m_LowerList, m_totalarea, and m_UpperList.

Referenced by Divide1().

◆ DoFirst()

void RoeDeer_Population_Manager::DoFirst ( void  )
protectedvirtual

DoFirst - for every time step, this function calls PreProcessLandscape, Clears fightlists for all males, creates several output files, such as deer location, deer home range, population age structure etc. Also, the average size of the male and female population is calculated to get dispersal thresholds and sums up the amount of floaters in the population

Reimplemented from Population_Manager.

441 {
442  int today=m_TheLandscape->SupplyDayInYear();
443  int year= m_TheLandscape->SupplyYear();
444 
445  //**ljk** commented out on May 11 2012
446  //StepCounter is incremented every timestep for as long as the simulation runs
447  if (StepCounter% 144==0) //new day
448  { //individual debug log files
449  //LOG(today,year);
450  //#ifndef __BATCH_VER
451  //OutputForm->Edit1->Text="Day: "+IntToStr(today);
452  //#endif
453  if (today==0) //once a year
454  {
455  // // // Update the year counter in MainForm
456  //#ifndef __BATCH_VER
457  //MainForm->Year++;
458  //MainForm->Edit1->Text=IntToStr(MainForm->Year);
459  //MainForm->Update();
460  //#endif
461  if(StepCounter!=0) //once a year, but not the first year
462  {
463  PreProcessLandscape(); //update the grid with qualities!!!
464  //clear fightlists for all males
465  for (unsigned i=0;i<5000;i++)
466  {
467  if(m_Fightlist[i]!=NULL)
468  {
469  for(unsigned j=0; j>m_Fightlist[i]->size();j++)
470  {
471  (*m_Fightlist[i])[j]=NULL;
472  }
473  }
474  delete m_Fightlist[i];
475  m_Fightlist[i]=NULL;
476  }
477  //tell all males that fightlists have been cleared
478  for(unsigned j=0;j<TheArray[1].size(); j++)
479  {
480  Roe_Male* deer;
481  deer = dynamic_cast< Roe_Male * > (TheArray[1][j]);
482  deer->ClearFightlist();
483  }
484  //write deadfile and clear list of dead animals
485  //WriteDeadFile("Mortality.txt",year);
486  //write age structure file
487  //WriteAgeStructFile("Agestruct.txt",year);
488  for(int i=0;i<2000;i++)
489  {
490  for(int j=0;j<2;j++)
491  {
492  DeadList[i][j] = 0;
493  }
494  }
495  }
496  }
497  if((today%30==0)&&(today!=0)) //every 30 days
498  {
499  //calculate average size of the male and female population to get dispersal thresholds
500  int malesize=0;
501  int femalesize=0;
502  int male_float=0;
503  int female_float=0;
504  for (unsigned i=1; i<TheArray.size();i++) //don't include fawns
505  {
506  for(unsigned j=0;j<TheArray[i].size(); j++)
507  {
508  Roe_Base* deer;
509  deer = dynamic_cast< Roe_Base * > (TheArray[i][j]);
510  #ifdef JUJ__Debug3
511  if(deer->IsAlive()!=0x0DEADC0DE)
512  {
513  m_TheLandscape ->Warn("Roe_Population_Manager:DoFirst(): Deadcode warning,deer!","");
514  exit( 1 );
515  }
516  #endif
517  #ifdef JUJ__Debug1
518  if(deer==NULL)
519  {
520  m_TheLandscape ->Warn("Roe_Population_Manager:DoFirst(): NULL pointer, deer!","");
521  exit( 1 );
522  }
523  #endif
524  if(i==1)
525  {
526  malesize += deer->m_Size; //males
527  //Sum up how many floaters in population
528  if(deer->m_HaveRange==false)male_float++;
529  }
530  else
531  {
532  femalesize += deer->m_Size; //females
533  //Sum up how many floaters in population
534  if(deer->m_HaveRange==false) female_float++;
535  }
536  }
537  }
538  //write this number to file for debug
539  //WriteFloatFile("Float.txt",male_float,female_float);
540 
541  //calculate dispersal threshold and min weights
542  if(TheArray[1].size()>0) //to avoid division with zero if no males
543  {
544  m_MaleDispThreshold = int (malesize/TheArray[1].size());
545  m_MinWeight_Males = int (m_MaleDispThreshold * 0.75);
547  }
548  if(TheArray[2].size()>0)
549  {
550  m_FemaleDispThreshold = int (femalesize/TheArray[2].size());
553  }
554  }
555  }
556 
557  //from year 10 (i.e. 2000) onwards, every 40 hrs, store the positions of all animals
558 
559  Roe_Base* deer;
560  if ((year >= 2000)&&(StepCounter%240==0))
561  {
562  for (unsigned i=1; i<TheArray.size();i++) //adults only
563  {
564  for(unsigned j=0;j<TheArray[i].size(); j++) //for every animal of each type
565  {
566  deer = dynamic_cast< Roe_Base * > (TheArray[i][j]);
567  #ifdef JUJ__Debug3
568  if(deer->IsAlive()!=0x0DEADC0DE)
569  {
570  m_TheLandscape ->Warn("Roe_Population_Manager:DoFirst():Deadcode warning, deer!","");
571  exit( 1 );
572  }
573  #endif
574  //m_FixCounter is initialised to 0 when assigned to a new deer,
575  //so increment after the first position has been added
576  int number=deer->m_FixlistNumber;
577  AnimalPosition xy = deer->SupplyPosition();
578  m_FixList[number][m_FixCounter[number]][0]=xy.m_x;
579  m_FixList[number][m_FixCounter[number]][1]=xy.m_y;
580  m_FixCounter[number]++;
581 
582  //every month = 18 locations, calculate MCP home range and write it to file
583  if(m_FixCounter[number]==18)
584  {
585  #ifdef JUJ__Debug1
586  if(deer==NULL)
587  {
588  m_TheLandscape ->Warn("Roe_Population_Manager:DoFirst(): NULL pointer, deer!","");
589  exit( 1 );
590  }
591  #endif
592  //CalculateArea(0,m_FixCounter[ID]-1,ID); //first and last position to be sorted
593  //deer->m_HomeRange = (float) m_totalarea/1000000; //sqkm
594  m_totalarea=0;
595  m_FixCounter[number] = 0; //this animals list is empty
596  //WriteToFixFile(deer);
597  //WriteToHRFile("HRFile.txt",month, year);
598  }
599  }
600  }
601  }
602  StepCounter++;
603 }
A class defining an animals position.
Definition: PopulationManager.h:170
unsigned m_x
Definition: PopulationManager.h:172
unsigned m_y
Definition: PopulationManager.h:173
int SupplyYear(void)
Definition: landscape.h:1611
int SupplyDayInYear(void)
Definition: landscape.h:1596
Definition: Roe_all.h:101
int m_Size
Definition: Roe_all.h:106
bool m_HaveRange
Definition: Roe_all.h:116
void ClearFightlist()
Definition: Roe_male.cpp:1757
int DeadList[2000][2]
Definition: Roe_all.h:504
void PreProcessLandscape()
Definition: Roe_Population_Manager.cpp:232
AnimalPosition SupplyPosition()
Definition: PopulationManager.cpp:1345

References Roe_Male::ClearFightlist(), DeadList, Roe_Base::IsAlive(), m_CriticalWeight_Females, m_CriticalWeight_Males, m_FemaleDispThreshold, m_Fightlist, m_FixCounter, m_FixList, Roe_Base::m_FixlistNumber, Roe_Base::m_HaveRange, m_MaleDispThreshold, m_MinWeight_Females, m_MinWeight_Males, Roe_Base::m_Size, Population_Manager::m_TheLandscape, m_totalarea, AnimalPosition::m_x, AnimalPosition::m_y, PreProcessLandscape(), StepCounter, Landscape::SupplyDayInYear(), TAnimal::SupplyPosition(), Landscape::SupplyYear(), Population_Manager::TheArray, and Landscape::Warn().

◆ GetFixList()

int RoeDeer_Population_Manager::GetFixList ( )
1321 {
1322  //runs through the Fixlist and returns a unique number to each adult animal
1323  bool found=false;
1324  int value =-1;
1325  for(int i=0;i<MaxNoDeer;i++)
1326  {
1327  if(m_FixCounter[i] == -1) //vacant list
1328  {
1329  found=true;
1330  m_FixCounter[i] = 0; // "0" means occupied
1331  value = i;
1332  break;
1333  }
1334  }
1335  if(!found) //no vacant list found...error
1336  {
1337  m_TheLandscape ->Warn("Roe_Population_Manager:GetFixList():List full!","");
1338  exit( 1 );
1339  }
1340  return value;
1341 }

References m_FixCounter, Population_Manager::m_TheLandscape, MaxNoDeer, and Landscape::Warn().

Referenced by CreateObjects().

◆ Init()

void RoeDeer_Population_Manager::Init ( void  )
virtual

RoeDeer_Population_Manager::Init - Initialises the run ( and is thus only accessed once at beginning), by checking for output probes, preprocess landscape to get the quality of grid cells in m_TheGrid, adds female and male objects for year 0 and loads state names. Calls functions PreProcessLandscape() and SupplyElementType().

76 {
77 
78  strcpy(m_SimulationName,"RoeDeer");
79 
80  //ljk added 22/8-2012
81  if ( cfg_RipleysOutput_used.value() ) {
83  }
86  } else ReallyBigOutputPrb=0;
87 
90 
91  //First thing to do is to preprocess landscape to get the quality of grid
92  //cells in m_TheGrid
93 
95 
96  int number=0; //number of each sex created
97  // Create the right number of males and females
98  switch(SimW)
99  {
100  case 2000:
101  number=50; //in 2x2
102  break;
103  case 5000:
104  number=80; //in 5x5
105  break;
106  case 7000:
107  number=250;
108  break;
109  case 10000:
110  number=500; //in 10x10
111  break;
112  default:
113  number = (int) (0.000005 * SimW * SimH);
114  }
115  Deer_struct* ads;
116  ads = new Deer_struct;
117  ads->Pop = this;
118  ads-> L = m_TheLandscape;
119  ads->mum = NULL;
120  ads->sex = true;
121  ads->group = -1; //in constructor
122  ads->ID = -1; //don't know yet
123  ads->size = -1; //in constructor
124  ads->age = 575; //born on average 1st of June. Just for 1st generation roe
126  for (int i=0; i<number; i++)
127  {
130  //make sure they are dropped in either forest or field
131  El = m_TheLandscape->SupplyElementType(ads->x,ads->y);
132  while((El!=tole_ConiferousForest)&&(El!=tole_DeciduousForest)&&
133  (El!=tole_MixedForest)&&(El!=tole_YoungForest)&&(El!=tole_Field))
134  {
137  El = m_TheLandscape->SupplyElementType(ads->x,ads->y);
138  }
139  CreateObjects(1,NULL,NULL,ads,1);
140  }
141  ads->sex=false; //females
142  for (int i=0; i<number; i++)
143  {
146  //make sure they are dropped in either forest or field
147  El = m_TheLandscape->SupplyElementType(ads->x,ads->y);
148  while((El!=tole_ConiferousForest)&&(El!=tole_DeciduousForest)&&
149  (El!=tole_MixedForest)&&(El!=tole_YoungForest)&&(El!=tole_Field))
150  {
153  El = m_TheLandscape->SupplyElementType(ads->x,ads->y);
154  }
155  CreateObjects(2,NULL,NULL,ads,1);
156  }
157  delete ads;
158 
159  // Set up the list names (i.e. what are our animals called in this simulation
160  m_ListNames[0]="Fawn";
161  m_ListNames[1]="Male Roe Deer";
162  m_ListNames[2]="Female Roe Deer";
164 
165  //load state names
166  StateNames[rds_Initialise] = "Initial State";
167  StateNames[rds_FOnMature] = "Female OnMature";
168  StateNames[rds_MOnMature] = "Male OnMature";
169  StateNames[rds_FUpdateGestation] = "Female Update Gestation";
170  StateNames[rds_FUpdateEnergy] = "Female Update Energy";
171  StateNames[rds_MUpdateEnergy] = "Male Update Energy";
172  StateNames[rds_FAUpdateEnergy] = "Fawn Update Energy";
173  StateNames[rds_FEstablishRange] = "Female Establish Range";
174  StateNames[rds_MEstablishRange] = "Male Establish Range";
175  StateNames[rds_MEstablishTerritory] = "Male Establish Territory";
176  StateNames[rds_FDisperse] = "Female Disperse";
177  StateNames[rds_MDisperse] = "Male Disperse";
178  StateNames[rds_FOnNewDay] = "Female OnNewDay";
179  StateNames[rds_MOnNewDay] = "Male OnNewDay";
180  StateNames[rds_FAOnNewDay] = "Fawn OnNewDay";
181  StateNames[rds_FFormGroup] = "Female Form Group";
182  StateNames[rds_FInHeat] = "Female In Heat";
183  StateNames[rds_FGiveBirth] = "Female Give Birth";
184  StateNames[rds_FCareForYoung] = "Female Care For Young";
185  StateNames[rds_FRun] = "Female Run";
186  StateNames[rds_MRun] = "Male Run";
187  StateNames[rds_FARunToMother] = "Fawn Run To Mother";
188  StateNames[rds_FRecover] = "Female Recover";
189  StateNames[rds_MRecover] = "Male Recover";
190  StateNames[rds_FARecover] = "Fawn Recover";
191  StateNames[rds_FIgnore] = "Female Ignore";
192  StateNames[rds_MIgnore] = "Male Ignore";
193  StateNames[rds_FEvade] = "Female Evade";
194  StateNames[rds_MEvade] = "Male Evade";
195  StateNames[rds_MEvade] = "Male Evade";
196  StateNames[rds_FAHide] = "Fawn Hide";
197  StateNames[rds_MFight] = "Male Fight";
198  StateNames[rds_MAttendFemale] = "Male Attend Female";
199  StateNames[rds_FRuminate] = "Female Ruminate";
200  StateNames[rds_MRuminate] = "Male Ruminate";
201  StateNames[rds_FARuminate] = "Fawn Ruminate";
202  StateNames[rds_FFeed] = "Female Feed";
203  StateNames[rds_MFeed] = "Male Feed";
204  StateNames[rds_FAFeed] = "Fawn Feed";
205  StateNames[rds_FASuckle] = "Fawn Suckle";
206  StateNames[rds_FMate] = "Female Mate";
207  StateNames[rds_MMate] = "Male Mate";
208  StateNames[rds_FDie] = "Female Die";
209  StateNames[rds_MDie] = "Male Die";
210  StateNames[rds_FADie] = "Fawn Die";
211  StateNames[rds_FDeathState] = "Female Death State";
212  StateNames[rds_MDeathState] = "Male Death State";
213  StateNames[rds_FADeathState] = "Fawn Death State";
214  StateNames[rds_FAInit] = "Fawn Initial State";
215 
216  //determine whether we should shuffle or sort or do nothing
217  BeforeStepActions[0] = 0; //'0' is shuffle, '1' is sortx, '2' is sorty, '3' is nothing
218  BeforeStepActions[1] = 0;
219  BeforeStepActions[2] = 0;
220  BeforeStepActions[3] = 0;
221  BeforeStepActions[4] = 0;
222 }
int random(int a_range)
Definition: ALMaSS_CmdLine.cpp:142
CfgBool cfg_ReallyBigOutput_used
CfgBool cfg_RipleysOutput_used
@ rds_MFeed
Definition: Roe_all.h:82
@ rds_MDisperse
Definition: Roe_all.h:57
@ rds_MRecover
Definition: Roe_all.h:69
@ rds_FAInit
Definition: Roe_all.h:93
@ rds_MRuminate
Definition: Roe_all.h:79
@ rds_FInHeat
Definition: Roe_all.h:62
@ rds_FARunToMother
Definition: Roe_all.h:67
@ rds_FEvade
Definition: Roe_all.h:73
@ rds_FFeed
Definition: Roe_all.h:81
@ rds_FOnNewDay
Definition: Roe_all.h:58
@ rds_MFight
Definition: Roe_all.h:76
@ rds_MAttendFemale
Definition: Roe_all.h:77
@ rds_FRuminate
Definition: Roe_all.h:78
@ rds_FAUpdateEnergy
Definition: Roe_all.h:52
@ rds_FDie
Definition: Roe_all.h:87
@ rds_FMate
Definition: Roe_all.h:85
@ rds_FGiveBirth
Definition: Roe_all.h:63
@ rds_FFormGroup
Definition: Roe_all.h:61
@ rds_FOnMature
Definition: Roe_all.h:47
@ rds_MOnMature
Definition: Roe_all.h:48
@ rds_MEstablishTerritory
Definition: Roe_all.h:55
@ rds_FUpdateGestation
Definition: Roe_all.h:49
@ rds_MEvade
Definition: Roe_all.h:74
@ rds_FEstablishRange
Definition: Roe_all.h:53
@ rds_FDisperse
Definition: Roe_all.h:56
@ rds_MDie
Definition: Roe_all.h:88
@ rds_FARuminate
Definition: Roe_all.h:80
@ rds_Initialise
Definition: Roe_all.h:46
@ rds_FARecover
Definition: Roe_all.h:70
@ rds_FRun
Definition: Roe_all.h:65
@ rds_FAOnNewDay
Definition: Roe_all.h:60
@ rds_FCareForYoung
Definition: Roe_all.h:64
@ rds_FUpdateEnergy
Definition: Roe_all.h:50
@ rds_MDeathState
Definition: Roe_all.h:91
@ rds_MRun
Definition: Roe_all.h:66
@ rds_FDeathState
Definition: Roe_all.h:90
@ rds_FRecover
Definition: Roe_all.h:68
@ rds_FADeathState
Definition: Roe_all.h:92
@ rds_FAHide
Definition: Roe_all.h:75
@ rds_MOnNewDay
Definition: Roe_all.h:59
@ rds_MEstablishRange
Definition: Roe_all.h:54
@ rds_FADie
Definition: Roe_all.h:89
@ rds_MMate
Definition: Roe_all.h:86
@ rds_FIgnore
Definition: Roe_all.h:71
@ rds_MUpdateEnergy
Definition: Roe_all.h:51
@ rds_FAFeed
Definition: Roe_all.h:83
@ rds_FASuckle
Definition: Roe_all.h:84
@ rds_MIgnore
Definition: Roe_all.h:72
const double InvCell_Size
Definition: Roe_constants.cpp:19
bool value(void)
Definition: configurator.h:135
Definition: Roe_all.h:437
RoeDeer_Population_Manager * Pop
Definition: Roe_all.h:443
TTypesOfLandscapeElement SupplyElementType(int a_polyref)
Definition: landscape.h:1110
FILE * ReallyBigOutputPrb
Definition: PopulationManager.h:595
const char * m_ListNames[32]
Definition: PopulationManager.h:537
char m_SimulationName[255]
Definition: PopulationManager.h:513
unsigned BeforeStepActions[12]
Definition: PopulationManager.h:542
const char * StateNames[100]
Definition: PopulationManager.h:531
bool OpenTheRipleysOutputProbe(string a_NWordFilename)
Definition: PopulationManager.cpp:757
unsigned m_ListNameLength
Definition: PopulationManager.h:538
bool OpenTheReallyBigProbe()
Definition: PopulationManager.cpp:859
void CreateObjects(int, TAnimal *pvo, void *null, Deer_struct *data, int number)
Definition: Roe_Population_Manager.cpp:1268
TTypesOfLandscapeElement
Definition: tole_declaration.h:36
@ tole_MixedForest
Definition: tole_declaration.h:53
@ tole_Field
Definition: tole_declaration.h:43
@ tole_DeciduousForest
Definition: tole_declaration.h:52
@ tole_YoungForest
Definition: tole_declaration.h:55
@ tole_ConiferousForest
Definition: tole_declaration.h:54

References Deer_struct::age, Population_Manager::BeforeStepActions, cfg_ReallyBigOutput_used, cfg_RipleysOutput_used, CreateObjects(), Deer_struct::group, Deer_struct::ID, InvCell_Size, m_gridextentx, m_gridextenty, Population_Manager::m_ListNameLength, Population_Manager::m_ListNames, Population_Manager::m_SimulationName, Population_Manager::m_TheLandscape, Deer_struct::mum, Population_Manager::OpenTheReallyBigProbe(), Population_Manager::OpenTheRipleysOutputProbe(), Deer_struct::Pop, PreProcessLandscape(), random(), rds_FADeathState, rds_FADie, rds_FAFeed, rds_FAHide, rds_FAInit, rds_FAOnNewDay, rds_FARecover, rds_FARuminate, rds_FARunToMother, rds_FASuckle, rds_FAUpdateEnergy, rds_FCareForYoung, rds_FDeathState, rds_FDie, rds_FDisperse, rds_FEstablishRange, rds_FEvade, rds_FFeed, rds_FFormGroup, rds_FGiveBirth, rds_FIgnore, rds_FInHeat, rds_FMate, rds_FOnMature, rds_FOnNewDay, rds_FRecover, rds_FRuminate, rds_FRun, rds_FUpdateEnergy, rds_FUpdateGestation, rds_Initialise, rds_MAttendFemale, rds_MDeathState, rds_MDie, rds_MDisperse, rds_MEstablishRange, rds_MEstablishTerritory, rds_MEvade, rds_MFeed, rds_MFight, rds_MIgnore, rds_MMate, rds_MOnMature, rds_MOnNewDay, rds_MRecover, rds_MRuminate, rds_MRun, rds_MUpdateEnergy, Population_Manager::ReallyBigOutputPrb, Deer_struct::sex, SimH, SimW, Deer_struct::size, Population_Manager::StateNames, Landscape::SupplyElementType(), Landscape::SupplySimAreaHeight(), Landscape::SupplySimAreaWidth(), tole_ConiferousForest, tole_DeciduousForest, tole_Field, tole_MixedForest, tole_YoungForest, CfgBool::value(), Deer_struct::x, and Deer_struct::y.

Referenced by RoeDeer_Population_Manager().

◆ InSquare()

bool RoeDeer_Population_Manager::InSquare ( int  p_x,
int  p_y,
int  p_sqx,
int  p_sqy,
int  p_range 
)
1584 {
1585  // are p_x & p_y in the square p_sqx,p_sqy,p_range?
1586  int x_extent = p_sqx+p_range;
1587  int y_extent = p_sqy+p_range;
1588  if (x_extent >= SimW)
1589  {
1590  if (y_extent >= SimH) // overlaps TR corner of sim area
1591  {
1592  // Top right square (limited by SimAreaHeight & SimAreaWidth
1593  if ((p_x >=p_sqx) && (p_y >=p_sqy)) return true;
1594  // Top Left Square (limited by 0,SimAreaHeight)
1595  if ((p_y >=p_sqy)&& (p_y<y_extent-SimH)) return true;
1596  // Bottom Left square (limited by 0,0)
1597  if ((p_x >=x_extent-SimW)&&(p_y<y_extent-SimH)) return true;
1598  // Bottom Right square (limited by SimAreaWidth,0)
1599  if ((p_x >=p_sqx)&& (p_y<y_extent-SimH)) return true;
1600 
1601  }
1602  else // Overlaps the western edge of the sim area
1603  {
1604  if ((p_x >=p_sqx) && (p_y >=p_sqy)&& (p_y<y_extent)) return true;
1605  if ((p_x <x_extent-SimW) && (p_y >=p_sqy)
1606  && (p_y<y_extent)) return true;
1607  }
1608  }
1609  else
1610  {
1611  if (y_extent >= SimH) // overlaps top of simulation area
1612  {
1613  if ((p_x >=p_sqx) && (p_x<x_extent) &&
1614  (p_y >=p_sqy)) return true;
1615  if ((p_x >=p_sqx) && (p_x<x_extent) &&
1616  (p_y<y_extent-SimH)) return true;
1617  }
1618  else // territory does not overlap end of simulation area
1619  {
1620  if ((p_x >=p_sqx) && (p_x<x_extent) &&
1621  (p_y >=p_sqy) && (p_y<y_extent)) return true;
1622  }
1623  }
1624  return false; // not in square
1625 }

References SimH, and SimW.

Referenced by SupplyFemaleRC(), SupplyFemales(), SupplyMaleRC(), SupplyMales(), and SupplyTMales().

◆ LOG()

void RoeDeer_Population_Manager::LOG ( int  day,
int  year 
)

◆ PercentForest()

double RoeDeer_Population_Manager::PercentForest ( int  p_x,
int  p_y,
int  p_range 
)

RoeDeer_Population_Manager::PercentForest - assesses the proportion of forest in given range, Calls functions ScanForPolys(), ScanForPolysModulus(), MagicMapP2PolyRef(), ForestSum().

122 {
123 
124  NoOfPolyrefs = 0;
125  OldPolyRef =-1;
126  OldPolyIndex =-1;
127 
128  int Start_x = p_x - p_range;
129  int End_x = p_x + p_range;
130  int Start_y = p_y - p_range;
131  int End_y = p_y + p_range;
132 
134 
135  // Clear the polygon reference array.
136  for ( int i=0; i<HASH_SIZE; i++ )
137  Polygonrefs[ i ] = -1;
138 
139  //First: get a list of polygons
140  if ((Start_x >=0)&&(Start_y >=0) &&
141  (End_x < SimW)&&(End_y < SimH)) {
142  //no overlap
143  ScanForPolys( Start_x, Start_y, End_x, End_y );
144  }
145  else {
146  //Overlap
147  ScanForPolysModulus( Start_x, Start_y,
148  End_x, End_y,
149  SimW, SimH );
150  }
151 
152  // Convert the Polygonrefs[] array from map magic numbers to polygon
153  // reference numbers.
154  for ( int i=0; i<HASH_SIZE; i++ ) {
155  if ( Polygonrefs [i] != -1 ) {
156  Polygonrefs [i] =
158  }
159  }
160 
161  //then get the element type of each polygon and multiply by area of polygon
162  double forest = ForestSum();
163  //return total forest divided by area of square
164  return (forest/(4*p_range*p_range))*100;
165 }
static int OldPolyIndex
Definition: Roe_range_qual.cpp:50
static void ScanForPolysModulus(int xmin, int ymin, int xmax, int ymax, int SimW, int SimH)
Definition: Roe_range_qual.cpp:291
static void ScanForPolys(int xmin, int ymin, int xmax, int ymax)
Definition: Roe_range_qual.cpp:198
static Landscape * LocalL
Definition: Roe_range_qual.cpp:58
static int NoOfPolyrefs
Definition: Roe_range_qual.cpp:59
static double ForestSum(void)
Definition: Roe_range_qual.cpp:602
static int Polygonrefs[HASH_SIZE]
Definition: Roe_range_qual.cpp:47
static int OldPolyRef
Definition: Roe_range_qual.cpp:49
#define HASH_SIZE
Definition: Roe_range_qual.cpp:44
int MagicMapP2PolyRef(int a_magic)
Definition: landscape.h:1516

References ForestSum(), HASH_SIZE, LocalL, NoOfPolyrefs, OldPolyIndex, OldPolyRef, Polygonrefs, ScanForPolys(), and ScanForPolysModulus().

Referenced by Roe_Female::FEstablishRange().

◆ PreProcessLandscape()

void RoeDeer_Population_Manager::PreProcessLandscape ( )

PreProcessLandscape starts at top-left corner (0,0) and runs through the whole landscape to create a grid of qualities. For each gridcell of a predefined size (=const int Cell_Size, minimum is 20x20) it evaluates the quality, using RangeQuality() and saves it in the array m_grid[][]. This map of qualities is constant throughout the simulation.

233 {
234 
235  int a_x = Cell_HalfSize;
236  int a_y = Cell_HalfSize; //centre of first cell
237  int row = SimH / Cell_Size;
238  int column = SimW / Cell_Size;
239  int value;
240 
241  for(int i=0;i<column;i++) //x-values, this many columns
242  {
243  for (int j=0;j<row;j++) //y-values, this many rows
244  {
245  value =(int) RangeQuality(a_x,a_y,Cell_HalfSize);
246  //add this value
247  m_TheGrid->AddGridValue(i,j,value);
248  a_y += Cell_Size; //move right to next column
249  }
250  a_x += Cell_Size; //move down to next row
251  a_y = Cell_HalfSize; //reset a_x to first cell in new row
252 
253  }
254 
255 /* //Lene: kommenter denne sektion ud naar du korer dine scenarier. Kun til at
256  //teste fordelingen af kvaliteter
257 //*************************************
258  int rand_x=-1;
259  int rand_y=-1;
260  int total=0;
261  for(int i=0;i<NoRandomAreas;i++)
262  {
263  rand_x= random(SimW);
264  rand_y= random(SimH);
265  total = ScanGrid(rand_x,rand_y,true);
266  WriteRandHR("RandomHR.txt", total);
267  total=0;
268  }
269 //**************************************
270  */
271 }
const int Cell_HalfSize
Definition: Roe_constants.cpp:20
const int Cell_Size
Definition: Roe_constants.cpp:18
bool AddGridValue(int x, int y, int value)
Definition: Roe_grid.cpp:32
double RangeQuality(int p_x, int p_y, int p_range)
Definition: Roe_range_qual.cpp:71

References Roe_Grid::AddGridValue(), Cell_HalfSize, Cell_Size, m_TheGrid, RangeQuality(), SimH, and SimW.

Referenced by DoFirst(), and Init().

◆ RangeQuality()

double RoeDeer_Population_Manager::RangeQuality ( int  p_x,
int  p_y,
int  p_range 
)

RangeQuality, calculates the quality of a grid cell of a predefined size (=const int Cell_Size, minimum is 20x20) using PolyArray2QualSum(). From this we get the quality of a polygon. The function then returns the total quality divided by area of square

72 {
73 
74  NoOfPolyrefs = 0;
75  OldPolyRef =-1;
76  OldPolyIndex =-1;
77 
78  int Start_x = p_x - p_range;
79  int End_x = p_x + p_range;
80  int Start_y = p_y - p_range;
81  int End_y = p_y + p_range;
82 
84 
85  // Clear the polygon reference array.
86  for ( int i=0; i<HASH_SIZE; i++ )
87  Polygonrefs[ i ] = -1;
88 
89  //First: get a list of polygons
90  if ((Start_x >=0)&&(Start_y >=0) &&
91  (End_x < SimW)&&(End_y < SimH)) {
92  //no overlap
93  ScanForPolys( Start_x, Start_y, End_x, End_y );
94  }
95  else {
96  //Overlap
97  ScanForPolysModulus( Start_x, Start_y,End_x, End_y, SimW, SimH );
98  }
99 
100  // Convert the Polygonrefs[] array from map magic numbers to polygon
101  // reference numbers.
102  for ( int i=0; i<HASH_SIZE; i++ ) {
103  if ( Polygonrefs [i] != -1 ) {
105  }
106  }
107 
108  //then get the element type of each polygon and multiply by area of polygon
109  double quality = PolyArray2QualSum();
110 
111  //return total quality divided by area of square
112  return quality/((2*p_range)*(2*p_range));
113 }
static double PolyArray2QualSum(void)
Definition: Roe_range_qual.cpp:392

References HASH_SIZE, LocalL, NoOfPolyrefs, OldPolyIndex, OldPolyRef, PolyArray2QualSum(), Polygonrefs, ScanForPolys(), and ScanForPolysModulus().

Referenced by PreProcessLandscape().

◆ RemoveFixList()

void RoeDeer_Population_Manager::RemoveFixList ( int  listno)

RoeDeer_Population_Manager::RemoveFixList - removes fixList of a particular deer object.

1347 {
1348 
1349  if(listno > MaxNoDeer) //invalid listref......error
1350  {
1351  m_TheLandscape ->Warn("Roe_Population_Manager:RemoveFixList():Invalid list number!","");
1352  exit( 1 );
1353  }
1354 
1355  m_FixCounter[listno] = -1;
1356  for(int i=0;i<20;i++)
1357  {
1358  m_FixList[listno][i][0] = 0;
1359  m_FixList[listno][i][1] = 0;
1360  }
1361 }

References m_FixCounter, m_FixList, Population_Manager::m_TheLandscape, MaxNoDeer, and Landscape::Warn().

Referenced by Roe_Female::FDie(), and Roe_Male::MDie().

◆ RemoveFromFightlist()

void RoeDeer_Population_Manager::RemoveFromFightlist ( Roe_Base deer)

RoeDeer_Population_Manager::RemoveFromFightlist - removes male object from fight list.

1490 {
1491  #ifdef JUJ__Debug3
1492  if(deer->IsAlive()!=0x0DEADC0DE)
1493  {
1494  m_TheLandscape ->Warn("Roe_Population_Manager:RemoveFromFightList():Deadcode warning,deer!","");
1495  exit( 1 );
1496  }
1497  #endif
1498  //remove this male from everybodys fightlist
1499  for (unsigned i=0;i<5000;i++)
1500  {
1501  if (m_Fightlist[i]!=NULL)
1502  {
1503  ListOfMales* fightlist = m_Fightlist[i];
1504  for (unsigned j=0;j<fightlist->size();j++) //every male in every list
1505  {
1506  #ifdef JUJ__Debug3
1507  Roe_Male* male=(*fightlist)[j];
1508  if(male->IsAlive()!=0x0DEADC0DE)
1509  {
1510  m_TheLandscape ->Warn("Roe_Population_Manager:RemoveFromFightList():Deadcode warning,male!","");
1511  exit( 1 );
1512  }
1513  #endif
1514  if((*fightlist)[j]==deer)
1515  {
1516  m_Fightlist[i]->erase(m_Fightlist[i]->begin()+j);
1517  }
1518  }
1519  }
1520  }
1521 }

References Roe_Base::IsAlive(), m_Fightlist, Population_Manager::m_TheLandscape, and Landscape::Warn().

Referenced by Roe_Male::MDie().

◆ RemoveFromGroup()

bool RoeDeer_Population_Manager::RemoveFromGroup ( Roe_Base p_deer,
int  TheGroup 
)

RoeDeer_Population_Manager::RemoveFromGroup - removes deer object from a group by erasing deer from list - if this causes group to have zero members, the entire group list will be deleted.

1431 {
1432  if(TheGroup != -1)
1433  {
1434  #ifdef JUJ__Debug1
1435  if(p_deer==NULL)
1436  {
1437  m_TheLandscape ->Warn("Roe_Population_Manager:RemoveFromGroup():NULL pointer,p_deer!","");
1438  exit( 1 );
1439  }
1440  if(m_GroupList[TheGroup]==NULL)
1441  {
1442  m_TheLandscape ->Warn("Roe_Population_Manager:RemoveFromGroup():NULL pointer,m_GroupList[TheGroup]!","");
1443  exit( 1 );
1444  }
1445  #endif
1446  #ifdef JUJ__Debug3
1447  if(p_deer->IsAlive()!=0x0DEADC0DE)
1448  {
1449  m_TheLandscape ->Warn("Roe_Population_Manager:RemoveFromGroup():Deadcode warning,p_deer!","");
1450  exit( 1 );
1451  }
1452  #endif
1453  #ifdef JUJ__Debug2
1454  if (TheGroup>4999)
1455  {
1456  m_TheLandscape ->Warn("Roe_Population_Manager:RemoveFromGroup():Variable out of range,TheGroup","");
1457  exit( 1 );
1458  }
1459  #endif
1460  int found=-1;
1461  int size= (int) m_GroupList[TheGroup]->size();
1462  for(int i=0;i<size;i++)
1463  {
1464  if(p_deer==(*m_GroupList[TheGroup])[i])
1465  {
1466  found=i;
1467  break;
1468  }
1469  }
1470  if(found!=-1)
1471  {
1472  // find and erase that deer
1473  m_GroupList[TheGroup]->erase(m_GroupList[TheGroup]->begin()+found);
1474  }
1475  //if group is now empty delete this group
1476  if(m_GroupList[TheGroup]->size()==0)
1477  {
1478  delete m_GroupList[TheGroup];
1479  m_GroupList[TheGroup]=NULL;
1480  m_NoGroups--;
1481  }
1482  }
1483  return true;
1484 }

References Roe_Base::IsAlive(), m_GroupList, m_NoGroups, Population_Manager::m_TheLandscape, and Landscape::Warn().

Referenced by Roe_Female::FFormGroup(), Roe_Female::FOnNewDay(), Roe_Fawn::On_ChangeGroup(), Roe_Fawn::~Roe_Fawn(), and Roe_Female::~Roe_Female().

◆ RunAfter()

void RoeDeer_Population_Manager::RunAfter ( )
protected
892 {
893  //TODO: Add your source code here
894 }

◆ RunBefore()

void RoeDeer_Population_Manager::RunBefore ( )
protected
887 {
888  //TODO: Add your source code here
889 }

◆ RunFirst()

void RoeDeer_Population_Manager::RunFirst ( )
protected
882 {
883  //TODO: Add your source code here
884 }

◆ RunLast()

void RoeDeer_Population_Manager::RunLast ( )
protected
897 {
898  //TODO: Add your source code here
899 }

◆ ScanGrid()

int RoeDeer_Population_Manager::ScanGrid ( int  p_x,
int  p_y,
bool  avq 
)

RoeDeer_Population_Manager::ScanGrid - adds up quality values stored in m_grid to see if a home range can be established here. Starts with a minimun area and extends it outwards until sufficient or maximum is reached. It returns the range size if the area is OK and zero if not. Uses functions Supply_GridCoord(), Supply_GridValue() and AddToArea().

281 {
282  /*
283  This function adds up quality values stored in m_grid to see if a home
284  range can be established here. Starts with a minimun area and extends it
285  outwards until sufficient or maximum is reached. It returns the range size
286  if the area is OK and zero if not.
287  */
288  //p_x and p_y are landscape coordinates, so find out what the grid coordinates
289  //are here
290  int g_x = m_TheGrid->Supply_GridCoord(p_x);
291  int g_y = m_TheGrid->Supply_GridCoord(p_y);
292  //what is the range measured in grid cells?
293  int less = int (MinRange * InvCell_Size);
294  //then find the starting coordinates in minimum area
295  int start_x = g_x - less;
296  int start_y = g_y - less;
297  int end_x = g_x + less;
298  int end_y = g_y + less;
299  int quality = 0;
300  int range = MinRange;
301  //First sum up minimum area = 2*MinRange x 2*Minrange
302  if ((start_x < less)||(start_y < less) ||
303  (end_x >= m_gridextentx - less) || (end_y >= m_gridextenty - less)) //cound be overlap
304  {
305  start_x += m_gridextentx;
306  start_y += m_gridextenty;
307  end_x += m_gridextentx;
308  end_y += m_gridextenty;
309 
310  for (int i=start_x; i< end_x; i++) //each column
311  {
312  for (int j=start_y; j<end_y; j++) //each row
313  {
315  }
316  }
317  //minimum area is evaluated. If this is for average range quality return
318  //quality here
319  if(avq) return quality;
320  else
321  {
322  while((quality <= MinRangeQuality)&&(range < MaxRange))
323  { //extend area outwards by adding layers of cells until quality is high enough
324  start_x --;
325  start_y --;
326  end_x ++;
327  end_y ++;
328  range += Cell_Size;
329 
330  quality += (AddToAreaCC(start_x%m_gridextentx, start_y%m_gridextenty, int(range*InvCell_Size)));
331  }
332  }
333  }
334  else //no overlap
335  {
336  for (int i=start_x; i<end_x; i++) //each column
337  {
338  for (int j=start_y; j<end_y; j++) //each row
339  {
340  quality += m_TheGrid->Supply_GridValue(i,j);
341  }
342  }
343  //minimum area is evaluated. If this is for average range quality return
344  //quality here
345  if(avq) return quality;
346  else
347  {
348  while((quality <= MinRangeQuality)&&(range < MaxRange))
349  { //extend area outwards by adding layers of cells until quality is high enough
350  start_x --;
351  start_y --;
352  end_x ++;
353  end_y ++;
354  range += Cell_Size;
355 
356  quality += (AddToArea(start_x, start_y, int(range*InvCell_Size)));
357  }
358  }
359  }
360  if(quality >= MinRangeQuality) //can set up range here
361  {
362  return range;
363  }
364  else return 0;
365 }
const int MinRange
Definition: Roe_constants.cpp:21
const int MinRangeQuality
Definition: Roe_constants.cpp:37
const int MaxRange
Definition: Roe_constants.cpp:22
int Supply_GridCoord(int p_coor)
Definition: Roe_grid.cpp:54
int AddToAreaCC(int g_x, int g_y, int p_range)
Definition: Roe_Population_Manager.cpp:404
int AddToArea(int g_x, int g_y, int p_range)
Definition: Roe_Population_Manager.cpp:373

References AddToArea(), AddToAreaCC(), Cell_Size, InvCell_Size, m_gridextentx, m_gridextenty, m_TheGrid, MaxRange, MinRange, MinRangeQuality, Roe_Grid::Supply_GridCoord(), and Roe_Grid::Supply_GridValue().

Referenced by Roe_Female::FOnMature(), Roe_Female::FOnNewDay(), Roe_Male::MOnMature(), Roe_Male::MOnNewDay(), and UpdateRanges().

◆ Sort()

void RoeDeer_Population_Manager::Sort ( int  ID,
int  p_a,
int  p_b 
)
1084 {
1085  //Quicksort of m_FixList by increasing x values. ID is the individual who's
1086  //positions we wish to sort. a and b are the first and last positions in the
1087  //we want sorted
1088  if (p_a<p_b)
1089  {
1090  int x = m_FixList[ID][(p_a+p_b)/2][0]; //middle element
1091  int i=p_a; //first position to be sorted
1092  int j=p_b; //last
1093  do
1094  {
1095  while (m_FixList[ID][i][0] < x) i++;
1096  while (m_FixList[ID][j][0] > x) j--;
1097  if (i<=j)
1098  {
1099  unsigned temp = m_FixList[ID][i][0];
1100  m_FixList[ID][i][0] = m_FixList[ID][j][0];
1101  m_FixList[ID][j][0] = temp; //swap i and j
1102  i++;
1103  j--;
1104  }
1105  } while (i<=j);
1106  Sort(ID,p_a,j); //recursive call
1107  Sort(ID,i,p_b);
1108  }
1109 }

References m_FixList.

Referenced by CalculateArea().

◆ Supply_AverageRangeQuality()

double RoeDeer_Population_Manager::Supply_AverageRangeQuality ( )
inline
514 {return m_AverageRangeQuality;}
double m_AverageRangeQuality
Definition: Roe_all.h:489

◆ Supply_GroupSize()

size_t RoeDeer_Population_Manager::Supply_GroupSize ( int  Group)
inline
513 {return m_GroupList[Group]->size();}

Referenced by Roe_Female::FFormGroup(), and Roe_Female::On_CanJoinGroup().

◆ Supply_RoeGroup()

ListOfDeer* RoeDeer_Population_Manager::Supply_RoeGroup ( int  Group)
inline
520 {return m_GroupList[Group];}

Referenced by Roe_Female::FFormGroup(), and Roe_Female::Send_EndGroup().

◆ SupplyFemaleRC()

ListOfFemales * RoeDeer_Population_Manager::SupplyFemaleRC ( int  p_x,
int  p_y,
int  SearchRange 
)

RoeDeer_Population_Manager::SupplyFemaleRC - searches a specific range, given coordinates and search range and returns list of female objects that have established ranges within the range.

1245 { //returns the females already established with a range within the square in
1246  //question. Uses m_OldRange
1247  ListOfFemales* LoF;
1248  LoF=new ListOfFemales;
1249  Roe_Female * female_ptr;
1250  // For each female on the global list
1251  for (unsigned j=0; j<TheArray[2].size(); j++) // '2' == females
1252  {
1253  // convert from TAnimal* to Roe_Female*
1254  female_ptr=dynamic_cast< Roe_Female * > (TheArray[2][j]);
1255  // Check if its range centre is in the square
1256  RoeDeerInfo range=female_ptr->SupplyInfo();
1257  int x=range.m_OldRange_x;
1258  int y=range.m_OldRange_y;
1259  if ((InSquare(x, y, p_x, p_y, SearchRange)) && (female_ptr->GetCurrentStateNo() != -1))
1260  {
1261  // It is so add it to the list of females
1262  LoF->push_back(female_ptr);
1263  }
1264  }
1265  return LoF;
1266 }
vector< Roe_Female * > ListOfFemales
Definition: Roe_all.h:40
RoeDeerInfo SupplyInfo()
Definition: Roe_base.cpp:1668
bool InSquare(int p_x, int p_y, int p_sqx, int p_sqy, int p_range)
Definition: Roe_Population_Manager.cpp:1582
Part of the basic ALMaSS system (obselete)
Definition: PopulationManager.h:187
unsigned m_OldRange_y
Definition: PopulationManager.h:194
unsigned m_OldRange_x
Definition: PopulationManager.h:193
int GetCurrentStateNo()
Returns the current state number.
Definition: PopulationManager.h:121

References TALMaSSObject::GetCurrentStateNo(), InSquare(), RoeDeerInfo::m_OldRange_x, RoeDeerInfo::m_OldRange_y, Roe_Base::SupplyInfo(), and Population_Manager::TheArray.

◆ SupplyFemales()

ListOfFemales * RoeDeer_Population_Manager::SupplyFemales ( int  p_x,
int  p_y,
int  SearchRange 
)

RoeDeer_Population_Manager::SupplyFemales - searches a specific range, given coordinates and search range and returns list of female objects within the range.

1217 {
1218  ListOfFemales* LoF;
1219  LoF=new ListOfFemales;
1220  Roe_Female * female_ptr;
1221  // For each female on the global list
1222  for (unsigned j=0; j<TheArray[2].size(); j++) // '2' == females
1223  {
1224  // convert from TAnimal* to Roe_Female*
1225  female_ptr=dynamic_cast< Roe_Female * > (TheArray[2][j]);
1226  // Check if it is in the square
1227  int x=female_ptr->Supply_m_Location_x();
1228  int y=female_ptr->Supply_m_Location_y();
1229  if ((InSquare(x, y, p_x, p_y, SearchRange)) && (female_ptr->GetCurrentStateNo() != -1))
1230  {
1231  // It is so add it to the list of females
1232  LoF->push_back(female_ptr);
1233  }
1234  }
1235  return LoF;
1236 }
int Supply_m_Location_x()
Definition: PopulationManager.h:213
int Supply_m_Location_y()
Definition: PopulationManager.h:216

References TALMaSSObject::GetCurrentStateNo(), InSquare(), TAnimal::Supply_m_Location_x(), TAnimal::Supply_m_Location_y(), and Population_Manager::TheArray.

Referenced by Roe_Female::FFormGroup().

◆ SupplyFightlist()

ListOfMales* RoeDeer_Population_Manager::SupplyFightlist ( int  ListNo)
inline
531  {if (ListNo!=-1) return m_Fightlist[ListNo];
532  else return NULL;}

◆ SupplyMaleRC()

ListOfMales * RoeDeer_Population_Manager::SupplyMaleRC ( int  p_x,
int  p_y,
int  SearchRange 
)

RoeDeer_Population_Manager::SupplyMaleRC - searches a specific range, given coordinates and search range and returns list of male objects with established ranges within the range.

1186  {
1187  ListOfMales* LoM;
1188  // Create a new list
1189  LoM=new ListOfMales;
1190  Roe_Male * male_ptr;
1191  // For each male on the global list
1192  for (unsigned j=0; j<TheArray[1].size(); j++) // '1' == males
1193  {
1194  // convert from TAnimal* to Roe_Male*
1195  male_ptr=dynamic_cast< Roe_Male * > (TheArray[1][j]);
1196  // Check if its range centre is in the square
1197  RoeDeerInfo range=male_ptr->SupplyInfo();
1198  int x=range.m_Range_x;
1199  int y=range.m_Range_y;
1200  if ((InSquare(x, y, p_x, p_y, SearchRange)) && (male_ptr->GetCurrentStateNo() != -1))
1201  {
1202  // It is so add it to the list of males
1203  LoM->push_back(male_ptr);
1204  }
1205  }
1206  // return the list
1207  return LoM;
1208  // NB Calling function has the responsibility of deleting the list after use!
1209  }
unsigned m_Range_y
Definition: PopulationManager.h:192
unsigned m_Range_x
Definition: PopulationManager.h:191

References TALMaSSObject::GetCurrentStateNo(), InSquare(), RoeDeerInfo::m_Range_x, RoeDeerInfo::m_Range_y, Roe_Base::SupplyInfo(), and Population_Manager::TheArray.

Referenced by Roe_Male::MOnNewDay().

◆ SupplyMales()

ListOfMales * RoeDeer_Population_Manager::SupplyMales ( int  p_x,
int  p_y,
int  SearchRange 
)

RoeDeer_Population_Manager::SupplyMaleRC - searches a specific range, given coordinates and search range and returns list of male objects within the range.

1155  {
1156  ListOfMales* LoM;
1157  // Create a new list
1158  LoM=new ListOfMales;
1159  Roe_Male * male_ptr;
1160  // For each male on the global list
1161  for (unsigned j=0; j<TheArray[1].size(); j++) // '1' == males
1162  {
1163  // convert from TAnimal* to Roe_Male*
1164  male_ptr=dynamic_cast< Roe_Male * > (TheArray[1][j]);
1165  // Check if it is in the square and has a territory
1166  int x=male_ptr->Supply_m_Location_x();
1167  int y=male_ptr->Supply_m_Location_y();
1168  if ((InSquare(x, y, p_x, p_y, SearchRange)) && (male_ptr->GetCurrentStateNo() != -1))
1169  {
1170  // It is so add it to the list of males
1171  LoM->push_back(male_ptr);
1172  }
1173  }
1174  // return the list
1175  return LoM;
1176  // NB Calling function has the responsibility of deleting the list after use!
1177  }

References TALMaSSObject::GetCurrentStateNo(), InSquare(), TAnimal::Supply_m_Location_x(), TAnimal::Supply_m_Location_y(), and Population_Manager::TheArray.

Referenced by Roe_Male::BeginStep(), Roe_Female::FInHeat(), Roe_Male::MDie(), and Roe_Male::On_IsDead().

◆ SupplyTMales()

ListOfMales * RoeDeer_Population_Manager::SupplyTMales ( int  p_x,
int  p_y,
int  SearchRange 
)

RoeDeer_Population_Manager::SupplyTMales - searches a specific range, given coordinates and search range and returns list of male objects that are territory holders within the range.

1120  {
1121  ListOfMales* LoTM;
1122  // Create a new list
1123  LoTM=new ListOfMales;
1124  Roe_Male * male_ptr;
1125  // For each male on the global list
1126  for (unsigned j=0; j<TheArray[1].size(); j++) // '1' == males
1127  {
1128  // convert from TAnimal* to Roe_Male*
1129  male_ptr=dynamic_cast< Roe_Male * > (TheArray[1][j]);
1130  {
1131  // Check if it is in the square and has a territory
1132  int x=male_ptr->Supply_m_Location_x();
1133  int y=male_ptr->Supply_m_Location_y();
1134  if (male_ptr->SupplyHaveTerritory())
1135  {
1136  if ((InSquare(x, y, p_x, p_y, SearchRange)) && (male_ptr->GetCurrentStateNo() != -1))
1137  {
1138  // It is so add it to the list of males
1139  LoTM->push_back(male_ptr);
1140  }
1141  }
1142  }
1143  }
1144  // return the list
1145  return LoTM;
1146  }
bool SupplyHaveTerritory()
Definition: Roe_all.h:420

References TALMaSSObject::GetCurrentStateNo(), InSquare(), TAnimal::Supply_m_Location_x(), TAnimal::Supply_m_Location_y(), Roe_Male::SupplyHaveTerritory(), and Population_Manager::TheArray.

Referenced by Roe_Male::MEstablishTerritory(), and Roe_Male::On_InHeat().

◆ TheAOROutputProbe()

void RoeDeer_Population_Manager::TheAOROutputProbe ( )
virtual

This method must be overridden in descendent classes

Reimplemented from Population_Manager.

1658  {
1659  m_AOR_Probe->DoProbe(2);
1660 }
virtual void DoProbe(int a_lifestage)
Definition: AOR_Probe.cpp:59
AOR_Probe * m_AOR_Probe
Definition: PopulationManager.h:526

References AOR_Probe::DoProbe(), and Population_Manager::m_AOR_Probe.

◆ TheRipleysOutputProbe()

void RoeDeer_Population_Manager::TheRipleysOutputProbe ( FILE *  a_prb)
virtual

An output designed to be used as an input to calculating Ripley's k in R.

Reimplemented from Population_Manager.

1641  { //ljk added 22/8-2012
1642  Roe_Female* FS;
1643  unsigned totalF=(unsigned) TheArray[2].size();
1644  int x,y;
1647  fprintf(a_prb,"%d %d %d %d %d\n", 0,w ,0, h, totalF);
1648  for (unsigned j=0; j<totalF; j++) //adult females
1649  {
1650  FS=dynamic_cast<Roe_Female*>(TheArray[2][j]);
1651  x=FS->Supply_m_Location_x();
1652  y=FS->Supply_m_Location_y();
1653  fprintf(a_prb,"%d\t%d\n", x,y);
1654  }
1655  fflush(a_prb);
1656 }

References Population_Manager::m_TheLandscape, TAnimal::Supply_m_Location_x(), TAnimal::Supply_m_Location_y(), Landscape::SupplySimAreaWidth(), and Population_Manager::TheArray.

◆ UpdateRanges()

void RoeDeer_Population_Manager::UpdateRanges ( )
606 {
607  Roe_Base* deer;
608 
609  for (unsigned listindex=1; listindex<TheArray.size();listindex++)
610  {
611  for (unsigned j=0; j<TheArray[listindex].size(); j++)
612  {
613  deer =dynamic_cast< Roe_Base * > (TheArray[listindex][j]);
614  RoeDeerInfo info = deer->SupplyInfo();
615  if(deer->m_HaveRange)
616  {
617  deer->m_SearchRange = ScanGrid(info.m_x,info.m_y,false);
618  }
619  }
620  }
621 }
int m_SearchRange
Definition: Roe_all.h:113
int ScanGrid(int p_x, int p_y, bool avq)
Definition: Roe_Population_Manager.cpp:280

References Roe_Base::m_HaveRange, Roe_Base::m_SearchRange, AnimalPosition::m_x, AnimalPosition::m_y, ScanGrid(), Roe_Base::SupplyInfo(), and Population_Manager::TheArray.

Member Data Documentation

◆ DeadList

int RoeDeer_Population_Manager::DeadList[2000][2]

◆ m_AverageRangeQuality

double RoeDeer_Population_Manager::m_AverageRangeQuality
protected

◆ m_CriticalWeight_Females

int RoeDeer_Population_Manager::m_CriticalWeight_Females

◆ m_CriticalWeight_Males

int RoeDeer_Population_Manager::m_CriticalWeight_Males

◆ m_FemaleDispThreshold

int RoeDeer_Population_Manager::m_FemaleDispThreshold

◆ m_Fightlist

ListOfMales* RoeDeer_Population_Manager::m_Fightlist[5000]
protected

◆ m_FixCounter

int RoeDeer_Population_Manager::m_FixCounter[5000]
protected

◆ m_FixList

int RoeDeer_Population_Manager::m_FixList[5000][20][2]
protected

Referenced by Divide1(), DoFirst(), RemoveFixList(), and Sort().

◆ m_gridextentx

int RoeDeer_Population_Manager::m_gridextentx
protected

The number of cells wide in the qual grid.

Referenced by AddToAreaCC(), Init(), and ScanGrid().

◆ m_gridextenty

int RoeDeer_Population_Manager::m_gridextenty
protected

The number of cells tall in the qual grid.

Referenced by AddToAreaCC(), Init(), and ScanGrid().

◆ m_GroupList

ListOfDeer* RoeDeer_Population_Manager::m_GroupList[5000]
protected

◆ m_LowerList

unsigned RoeDeer_Population_Manager::m_LowerList[100][2]
protected

Referenced by Divide1(), and Divide2().

◆ m_MaleDispThreshold

int RoeDeer_Population_Manager::m_MaleDispThreshold

◆ m_MinWeight_Females

int RoeDeer_Population_Manager::m_MinWeight_Females

◆ m_MinWeight_Males

int RoeDeer_Population_Manager::m_MinWeight_Males

◆ m_MoveMap

MovementMap* RoeDeer_Population_Manager::m_MoveMap

Map of suitability for movement.

Referenced by RoeDeer_Population_Manager().

◆ m_NoGroups

int RoeDeer_Population_Manager::m_NoGroups
protected

◆ m_TheGrid

Roe_Grid* RoeDeer_Population_Manager::m_TheGrid
protected

◆ m_totalarea

long RoeDeer_Population_Manager::m_totalarea
protected

◆ m_UpperList

unsigned RoeDeer_Population_Manager::m_UpperList[100][2]
protected

Referenced by Divide1(), and Divide2().

◆ SimH

int RoeDeer_Population_Manager::SimH

◆ SimW

int RoeDeer_Population_Manager::SimW

◆ StepCounter

long RoeDeer_Population_Manager::StepCounter

◆ Turnover

int RoeDeer_Population_Manager::Turnover
protected

The documentation for this class was generated from the following files: